<template>
  <div class="common-layout">
    <el-container style="height: 100%;">
    <el-aside width="280px" style="height: 100%;">
      <StudentNav v-if="identity ==='学生'" />
      <TeacherNav v-if="identity ==='教师'"/>
      <AdminNav v-if="identity ==='管理员'" />
    </el-aside>
    <el-container>
      <el-header>
        <MainHeader/>
      </el-header>
      <el-main>
        <el-page-header @back="goBack" :content="content">
        </el-page-header>
        <keep-alive>
          <router-view></router-view>
        </keep-alive>
      </el-main>
    </el-container>
  </el-container>
  </div>
</template>

<script>
import MainHeader from '@/components/MainHeader.vue'
import StudentNav from './Nav/StudentNav.vue'
import TeacherNav from './Nav/TeacherNav.vue'
import AdminNav from './Nav/AdminNav.vue'
export default {
  name:'mainPage',
  components:{
    MainHeader,
    StudentNav,
    TeacherNav,
    AdminNav
  },
  data(){
    return{
      identity:localStorage.getItem('identity'),
      content:'基本信息'
    }
  },
  methods:{
    goBack() {
      this.$router.back()
    }
  },
  watch:{
    $route(){
      this.content=this.$route.name
    }
  },
  mounted(){
    this.content=this.$route.name
  }
}
</script>

<style>
.el-aside::-webkit-scrollbar {
  display: none;
}
.navTitle{
  position: relative;
  color: #eeecec;
  padding: 7px 0;
  padding-left: 22px;
  text-align: center;
}
.navTitle::before{
  content: '';
  position: absolute;
  background: url(../assets/logo.jpg) no-repeat;
  width: 36px;
  height: 36px;
  display: inline-block;
  background-size: cover;
  border-radius: 18px;
  top:6px;
  left: 37px;
}
.el-header{
  padding: 0;
}
.el-page-header{
  padding: 0 5px 10px;
}
.el-main{
  margin-top:22px;
}
html,
body,
#app,
.common-layout,
.el-constainer{
  padding: 0;
  margin: 0;
  height: 100%;
}
</style>